package project.controllers.workers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import project.model.IMaster;

public class WorkerWithMaster {
	private static final String MASTER="Master ";
	private static final String PERFORMS= " performs order #";
	private static final String BUSY= " busy";
	private static final String FREE = " free";

	static void getOrdersByMaster(IMaster master) {
		System.out.println(MASTER + master.getNameMaster()
				+ PERFORMS + master.getOrder().getNumberOrder());
	}

	static void SortMaster(ArrayList<IMaster> masterList, Comparator sortBy) {
		Collections.sort(masterList, sortBy);
		for (IMaster master : masterList) {
			if (master.getEmploymentMaster()) {
				System.out
						.println(MASTER + master.getNameMaster() + BUSY);
			} else {
				System.out
						.println(MASTER + master.getNameMaster() + FREE);
			}
		}
	}

	static void addMaster(ArrayList<IMaster> masterList, IMaster master) {
		masterList.add(master);
	}

	static void deleteMaster(ArrayList<IMaster> masterList,
			IMaster master) {
		ArrayList<IMaster> temp = new ArrayList<IMaster>();
		for (IMaster mas : masterList) {
			if (!mas.equals(master)) {
				temp.add(mas);
			}
		}
		masterList.clear();
		masterList.addAll(temp);
	}
}
